﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbDoc.BusinessObjects;
using System.Collections.ObjectModel;
using DbDoc.BusinessManager;

namespace DbDoc.PowerDoc.ViewModel
{
    class CommentHistoryViewModel : ViewModelBase
    {

        private DbObject _DbObject;
        private string _HeaderMessage;

        private ObservableCollection<Comment> _Comments;

        public ObservableCollection<Comment> Comments
        {
            get { return _Comments; }
            set { _Comments = value;
            OnPropertyChanged("Comments");
            }
        }

        
        public DbObject SelectedObject
        {
            get { return _DbObject; }
            set { _DbObject = value; }
        }

        public string HeaderMessage
        {
            get
            {
                if (_HeaderMessage == null)
                    _HeaderMessage = string.Format("Comments History for {0}", SelectedObject.Name);

                return _HeaderMessage;
            }
            set
            {
                _HeaderMessage = value;
                OnPropertyChanged("HeaderMessage");
            }
        }

        public CommentHistoryViewModel(DbObject obj)
        {
            SelectedObject = obj;
            _Comments = new ObservableCollection<Comment>(DatabaseManager.GetCommentsHistory(SelectedObject));
        }
    }
}
